<?php 
function categoriasRecursivas($categorias, $separador = "", $i=0){
	if($categorias){
 		foreach($categorias as $categoria){
 			?>
 			<tr>
      			<td class="col-chk"><input type="checkbox"/></td>
      			<td class="col-first--"><?php echo $categoria->id; ?></td>
      			<td class="col-second"><?php echo $separador . $categoria->name; ?></td>
      			<td class="row-nav">
      				<a class="table-edit-link" href="<?php echo site_url("admin/categories/edit/" . $categoria->id)?>">Edit</a> <span class="hidden"> | </span> 
      				<a class="table-delete-link" href="<?php echo site_url("admin/categories/delete/" . $categoria->id)?>" onclick="return confirm('¿Desea eliminar la categoria?')">Delete</a>
      			</td>
      		</tr>
 			
 			<?php 
 			$i++;
 			
 			if(isset($categoria->categories) && count($categoria->categories)>0){
 				categoriasRecursivas($categoria->categories, $separador . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", $i);
 			}
 		}
	}
}

?>
		
		<div id="content-top">
			<h2>Categorias</h2>
			<a id="topLink" href="#">Change Order</a> 
			<span class="clearFix"> </span>
		</div><!-- end of div#content-top -->
		
		<div id="left-col">
		 	
		 	<?php $this->load->view($template_path ."pages/categories/commons/menu");?>
			
		 </div><!-- end of #left-col -->
		 
		 <div id="mid-col" class="full-col">
		 
		 	<div class="box">
      		<h4 class="white">Categorias <a class="heading-link" href="<?php echo site_url("admin/categories/add");?>">Añadir categoria</a></h4>
        	<div class="box-container">     		
      		<table class="list">
      			<thead>
      				<tr>
      					<td></td>
      					<td>Id</td>
      					<td>Nombre</td>
      					<td>Acciones</td>
      				</tr>
      			</thead>
      			<!-- 
      			<tfoot>
      				<tr>
      					<td class="col-chk"><input type="checkbox"/></td>
      					<td colspan="4"><div class="align-right"><select class="form-select"><option value="option1">Bulk Options</option>
      					<option value="option2">Delete All</option></select>
      					<a class="button" href="#"><span>perform action</span></a></div></td>
      				</tr>
      			</tfoot>
      			-->
      			<tbody>
      				<?php 
				 	/*			
	 				$this->load->helper('generate_list');
					
					$options = array(
						'level'=>0,
						'indent'=>'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|',
						'alternate'=>array('class="odd"', 'class="even"')
					);
					$template = '<option value="{ID}">{INDENT}- {NAME}</option>{SUBS}';
					
					$template = '<tr {ALTERNATE}>'.
      					'<td class="col-chk"><input type="checkbox"/></td>'.
		      			'<td class="col-first--">{ID}</td>'.
		      			'<td class="col-second">{INDENT}- {NAME}</td>'.
		      			'<td class="row-nav">'.
		      				'<a class="table-edit-link" href="'.site_url("admin/categories/edit").'/{ID}">Edit</a> <span class="hidden"> | </span>'. 
		      				'<a class="table-delete-link" href="'.site_url("admin/categories/delete").'/{ID}" onclick="return confirm(\"¿Desea eliminar la categoria?\");">Delete</a>'.
		      			'</td>'.
		      		'</tr>{SUBS}';
					
					echo generate_list($categorias, $options, $template); 
					*/
	 				?>
	 				
	 				<?php if ($categorias): ?>
						<?php categoriasRecursivas($categorias, ""); ?>
					<?php endif; ?>
      			</tbody>
      		</table>  	
      	</div><!-- end of div.box-container -->
      	</div> <!-- end of div.box -->
		 
		</div><!-- end of #mid-col --> 